package com.love.driver.api.factory;


import com.love.common.core.domain.R;
import com.love.driver.api.RemoteDriverService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteDriverFallbackFactory implements FallbackFactory<RemoteDriverService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteDriverFallbackFactory.class);

    @Override
    public RemoteDriverService create(Throwable throwable) {

        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new RemoteDriverService()
        {
            @Override
            public R<Boolean> testDriverFeign(String source)
            {
                return R.fail("远程调用日志失败:" + throwable.getMessage());
            }
        };
    }
}
